package me.chenqiang.cinc;

import static org.junit.Assert.assertEquals;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SimpleTestCase {
	public static final Logger LOGGER = LoggerFactory.getLogger(SimpleTestCase.class);

	@Test
	public void testCincSamples() throws IOException {
		try (BufferedReader reader = new BufferedReader(new InputStreamReader(
				CincRelatedTestCase.class.getResourceAsStream("/samples.txt"), StandardCharsets.UTF_8))) {			
			reader.lines().forEach(line -> {
				try {
					line = line.strip();
					String forward = CincCoder.encode(line);
					System.out.println(String.format("%s => %s", line, forward));							
					String backward = CincCoder.decode(forward).getValue();
					System.out.println(String.format("%s <= %s", forward, backward));
					assertEquals(line, backward);					
					
				} catch (CincCodingException e) {
					LOGGER.error(line, e);
				}
			});
		} finally {

		}
	}
}
